package com.jlect.swebing.util.client;

import com.google.gwt.core.client.GWT;

/**
 * Logger class for logging
 *
 * @author Sergey Kozmin
 * @since 25.11.2007 18:56:57
 */
public class Logger {
    private String loggerId;

    private Logger(String loggerId) {
        this.loggerId = loggerId;
    }

    public static Logger getLogger(Object object) {
        return getLogger(GWT.getTypeName(object));
    }

    public static Logger getLogger(String name) {
        return new Logger(name);
    }

    public void info(java.lang.Object message)  {
        log(Priority.INFO, message);
    }

    public void info(java.lang.Object message, java.lang.Throwable t) {
        log(Priority.INFO, message, t);
    }

    public void warn(java.lang.Object message)  {
        log(Priority.WARN, message);
    }

    public void warn(java.lang.Object message, java.lang.Throwable t) {
        log(Priority.WARN, message, t);
    }

    public void error(java.lang.Object message)  {
        log(Priority.ERROR, message);
    }

    public void error(java.lang.Object message, java.lang.Throwable t) {
        log(Priority.ERROR, message, t);
    }

    public void log(Priority priority, java.lang.Object message) {
        log(priority, message, null);
    }

    public void log(Priority priority, java.lang.Object message, java.lang.Throwable t) {
        //todo implement appenders here
        String string = "[" + loggerId + "] " + "[" + priority.toString() + "] : " + message;
        System.out.println(string);
        if(t != null) {
            t.printStackTrace(System.out);
        }
    }
}
